package cn.iocoder.yudao.module.crossborder.crm.api;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.crossborder.crm.api.dto.CustomerDTO;
import cn.iocoder.yudao.module.crossborder.crm.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 客户关系管理 API 接口
 *
 * @author LHL
 */
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿：fallbackFactory =
@Tag(name = "RPC 服务 - 客户关系管理")
public interface CrmApi {

    String PREFIX = ApiConstants.PREFIX + "/crm";

    @GetMapping(PREFIX + "/customer/get")
    @Operation(summary = "获得客户信息")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    CommonResult<CustomerDTO> getCustomer(@RequestParam("id") @NotNull Long id);

    @GetMapping(PREFIX + "/customer/list")
    @Operation(summary = "获得客户信息列表")
    @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
    CommonResult<List<CustomerDTO>> getCustomerList(@RequestParam("ids") @NotNull List<Long> ids);

    @PostMapping(PREFIX + "/customer/create")
    @Operation(summary = "创建客户信息")
    CommonResult<Long> createCustomer(@RequestBody @Valid CustomerDTO customer);

    @GetMapping(PREFIX + "/customer/validate")
    @Operation(summary = "校验客户是否存在")
    @Parameter(name = "customerId", description = "客户编号", required = true, example = "1024")
    CommonResult<Boolean> validateCustomer(@RequestParam("customerId") @NotNull Long customerId);

    @GetMapping(PREFIX + "/customer/search")
    @Operation(summary = "搜索客户")
    @Parameter(name = "keyword", description = "搜索关键词", required = true, example = "张三")
    CommonResult<List<CustomerDTO>> searchCustomers(@RequestParam("keyword") @NotNull String keyword);

}
